let initState = {
    // 持久化处理
    token:localStorage.getItem("USER_TOKEN") || null
}

function tokenReducer(state=initState,action){
    switch(action.type){
        case "SET_TOKEN":
            let newState = {...state}
            newState.token = action.token;
            return newState;
        case "CLEAR_TOKEN":
                let newStates = {...state}
                newStates.token = action.token;
                return newStates;
         default:
            return state;
    }
}

export default tokenReducer;